package com.xiangyu.demo;

import com.xiangyu.demo.filter.CustomFilter;
import com.xiangyu.demo.interceptor.MyInterceptor2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

/**
 * java类简单作用描述
 *
 * @ProjectName: springboot-demo
 * @Package: com.xiangyu.demo
 * @Description: java类作用描述
 * @Author: 向羽
 * @CreateDate: 2018/1/10 18:54
 * @UpdateUser: 向羽
 * @UpdateDate: 2018/1/10 18:54
 * @UpdateRemark: The modified content
 * @Version: 2.0
 */
/*@EnableAutoConfiguration
@ComponentScan(basePackages={"com.xiangyu.demo"})*/
@EnableTransactionManagement // 启注解事务管理，等同于xml配置方式的 <tx:annotation-driven />
@SpringBootApplication(scanBasePackages = {"com.xiangyu.demo"})
public class Application {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public FilterRegistrationBean addFilterRegistrationBean(){
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new CustomFilter());
        registration.addUrlPatterns("/*");
        registration.addInitParameter("paramName", "paramValue");
        registration.setName("sessionFilter");
        return registration;
    }

}
